<?php
/**
 * @version		2.0.1 | $Id: team_table.php 210 2010-06-14 21:07:35Z mwi.nor $
 */

// no direct access
defined( '_JEXEC' ) or die();
	$cparams =& JComponentHelper::getParams('com_matchdart');
?>
<?php if ($cparams->get('show_page_title', 1)) : ?>
<div class="componentheading<?php echo $this->escape($cparams->get('pageclass_sfx')); ?>">
	<?php echo $cparams->get('page_title'); ?>
</div>
<?php endif; ?>

<div class="contentheading<?php echo $this->escape($cparams->get('pageclass_sfx')); ?>">
<?php echo $this->event->EventName.' - '.$this->season->SeasonName ?>
</div>

<?php if ( $cparams->get( 'md_show_eventlogo' )) : ?> 
	<div align="center">
		<?php echo '<img src="'.$this->event->EventLogo.'" alt="MD_EVENT_LOGO">' ?>
	</div>
<?php endif; ?>

<?php 
	$block1 = 5;
	$block2 = 3;
	$block3 = 4;
	
	if ($this->event->EventUseDraws == 1) {
		$block1++;
		$block2++;
	}
	if ($this->event->EventUseSets == 1) {
		$block2 = $block2 + 3;
	}
	if ($this->event->EventUseXStats == 1) {
		$block3 = $block3 + 2;
	}
?>

<table class="contentpane<?php echo $cparams->get('pageclass_sfx'); ?>">
	<tr>
		<td colspan="<?php echo $block1; ?>" >&nbsp;</td>
		<td colspan="<?php echo $block2; ?>" align="center" class="sectiontableheader<?php echo $this->escape($cparams->get('pageclass_sfx')); ?>"><?php echo JText::_( 'MD_TABLE_IND_MATCH' ); ?></td>
		<td colspan="<?php echo $block3; ?>" align="center" class="sectiontableheader<?php echo $this->escape($cparams->get('pageclass_sfx')); ?>"><?php echo JText::_( 'MD_TABLE_STATS' ); ?></td>
	</tr>
	<tr class="sectiontableheader<?php echo $this->escape($cparams->get('pageclass_sfx')); ?>">
    	<td align="center"><?php echo JText::_( 'MD_TABLE_POSITION' ); ?></td>
    	<td align="center"><?php echo JText::_( 'MD_TABLE_TEAM_NAME' ); ?></td>
    	<td align="center"><?php echo JText::_( 'MD_TABLE_TEAM_MATCHES' ); ?></td>
    	<td align="center"><?php echo JText::_( 'MD_TABLE_TEAM_WIN' ); ?></td>
    	<?php if ($this->event->EventUseDraws == 1) : ?>
    	<td align="center"><?php echo JText::_( 'MD_TABLE_TEAM_DRAW' ); ?></td>
    	<?php endif; ?>
    	<td align="center"><?php echo JText::_( 'MD_TABLE_TEAM_LOSE' ); ?></td>
    	<?php if ($this->event->EventUseSets == 1) : ?>
	    	<td align="center"><?php echo JText::_( 'MD_TABLE_SETSWIN' ); ?></td>
    		<td align="center"><?php echo JText::_( 'MD_TABLE_SETSLOSE' ); ?></td>
    		<td align="center"><?php echo JText::_( 'MD_TABLE_SETSDIFF' ); ?></td>
    	<?php endif; ?>
    	<td align="center"><?php echo JText::_( 'MD_TABLE_WIN' ); ?></td>
    	<?php if ($this->event->EventUseDraws == 1) : ?>
    	<td align="center"><?php echo JText::_( 'MD_TABLE_DRAW' ); ?></td>
    	<?php endif; ?>
    	<td align="center"><?php echo JText::_( 'MD_TABLE_LOSE' ); ?></td>
    	<td align="center"><?php echo JText::_( 'MD_TABLE_DIFF' ); ?></td>
    	<td align="center"><?php echo JText::_( 'MD_TABLE_LWAT' ); ?></td>
    	<?php if ($this->event->EventUseXStats == 1) : ?>
    	<td align="center"><?php echo JText::_( 'MD_TABLE_100' ); ?></td>
    	<td align="center"><?php echo JText::_( 'MD_TABLE_140' ); ?></td>
    	<?php endif; ?>
    	<td align="center"><?php echo JText::_( 'MD_TABLE_180' ); ?></td>
    	<td align="center"><?php echo JText::_( 'MD_TABLE_HC' ); ?></td>
    	<td align="center"><?php echo JText::_( 'MD_TABLE_POINTS' ); ?></td>
	</tr>
<?php
    $items =& $this->items;
    $drawline = explode( ",", $this->event->EventLine );
    $pos = 1; 
    $odd = 0; 
    
    foreach($items as $item) : ?>
		<tr class="sectiontableentry<?php echo $odd+1 . $this->escape($cparams->get('pageclass_sfx')); ?>">
	    	<td align="right"><?php echo $pos; ?></td>
	    	<td><?php echo $item->TeamName; ?></td>
	    	<td align="right"><?php echo $item->TotalMatches; ?></td>
	    	<td align="right"><?php echo $item->TotalMatchWins; ?></td>
	    	<?php if ($this->event->EventUseDraws == 1) : ?>
	    	<td align="right"><?php echo $item->TotalMatchDraws; ?></td>
	    	<?php endif; ?>
	    	<td align="right"><?php echo $item->TotalMatchLoses; ?></td>
	    	<?php if ($this->event->EventUseSets == 1) : ?>
		    	<td align="right"><?php echo $item->TeamTotalSetsWin; ?></td>
	    		<td align="right"><?php echo $item->TeamTotalSetsLose; ?></td>
	    		<td align="right"><?php echo $item->TeamTotalSetsDiff; ?></td>
	    	<?php endif; ?>
	    	<td align="right"><?php echo $item->TotalWins; ?></td>
	    	<?php if ($this->event->EventUseDraws == 1) : ?>
    		<td align="right"><?php echo $item->TotalDraws; ?></td>
	    	<?php endif; ?>
    		<td align="right"><?php echo $item->TotalLoses; ?></td>
	    	<td align="right"><?php echo $item->TotalDiff; ?></td>
	    	<td align="right"><?php echo $item->TotalLWAT; ?></td>
	    	<?php if ($this->event->EventUseXStats == 1) : ?>
	    	<td align="right"><?php echo $item->Total100; ?></td>
	    	<td align="right"><?php echo $item->Total140; ?></td>
	    	<?php endif; ?>
	    	<td align="right"><?php echo $item->Total180; ?></td>
	    	<td align="right"><?php echo $item->TotalHC; ?></td>
	    	<td align="right" class="highlight<?php echo $this->escape($cparams->get('pageclass_sfx')); ?>"><?php echo $item->TotalPoints; ?></td>
    	</tr>
		<?php if (in_array($pos, $drawline)) : ?>
			<tr class="sectiontableentry1<?php echo $this->escape($cparams->get('pageclass_sfx')); ?>">
				<td height="5" colspan="18" align="center" valign="middle">
					<img src="components/com_matchdart/images/line.gif" width="98%" height="5" alt="MD_LINE">
				</td>
			</tr>
		<?php endif; ?>
    	
	<?php 
	$pos++;
	$odd = 1 - $odd;
	endforeach; ?>
	<tfoot>
		<tr class="sectiontablefooter<?php echo $this->escape($cparams->get('pageclass_sfx')); ?>">
			<td colspan="18" class="createdate"><?php echo $this->lastupdate; ?></td>
		</tr>
		<tr>
			<td colspan="18" class="small"><?php echo $this->event->EventTableLegend; ?></td>
		</tr>
	</tfoot>
</table>
